perf: Allow to pass a selector to useWindowDimensions(state => state.fontScale) to avoid unnecessary re-renders - #57185
Conversation
….fontScale)` to avoid unnecessary re-renders
|
Warning JavaScript API change detected This PR commits an update to
This change was flagged as: |
|
Hey @cortinico ! Do you know somebody in Meta who can review this PR ? |
Potentially @javache |
|
@javache Could you please review this PR? |
|
I'm hesitant to addd this as a core API since React hasn't moved ahead with context selectors (react/react#20646) either. My assumption is that when using React compiler, this type of memoization should be equivalent, and React should be able to bail out from rendering fairly quickly. Is that not what you're observing? Alternatively, you could build this type of hook yourself using the existing public React Native API, no? |
|
Thank you! |
Summary:
Performance issue was shown on App.js 2026 Conf: https://www.youtube.com/live/4H8iRPN0Q2M?si=pykgDXJcbvi7_OIC&t=8704 by @jmeistrich
Changelog:
[GENERAL] [ADDED] - Allow to pass a selector to
useWindowDimensions(state => state.fontScale)to avoid unnecessary re-rendersTest Plan:
I did my best to cover all testcases: